import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/vue-element-admin/user/login',
    method: 'post',
    data
  })
}

// 商户端-账号密码登陆
export function password(data) {
  return request({
    url: '/jbl-user-center/api/merchant/v1/sysUser/login',
    method: 'post',
    data: data
  })
}

// 商户端-更换手机号
export function changePhone(data) {
  return request({
    url: '/jbl-user-center/api/merchant/v1/sysUser/changePhone',
    method: 'post',
    data: data
  })
}

// 商户端-通过原密码-重置密码
export function setPasswordByOldPwd(data) {
  return request({
    url: '/jbl-user-center/api/merchant/v1/sysUser/setPasswordByOldPwd',
    method: 'post',
    data: data
  })
}

// 机构端-退出登陆
export function loginOut(data) {
  return request({
    url: '/jbl-user-center/api/common/v1/loginOut',
    method: 'get',
    params: data
  })
}

// 获取用户菜单
export function getUserMenu(data) {
  return request({
    url: '/jbl-user-center/api/merchant/v1/sysPermission/getUserMenu',
    method: 'get',
    params: data
  })
}
// 获取用户权限菜单
export function getUserPermissionMenu(data) {
  return request({
    url: '/jbl-user-center/api/merchant/v1/sysPermission/getUserCascadeList',
    method: 'get',
    params: data
  })
}

// 商户端-发送验证码
export function sendCode(data) {
  return request({
    url: '/jbl-user-center/api/common/v1/sendCode',
    method: 'post',
    data: data
  })
}

// 商户端-发送验证码
export function setPassword(data) {
  return request({
    url: '/jbl-user-center/api/merchant/v1/sysUser/setPassword',
    method: 'post',
    data: data
  })
}

// 商户端-手机验证码登陆
export function loginByPhoneAndCode(data) {
  return request({
    url: '/jbl-user-center/api/merchant/v1/sysUser/loginByPhoneAndCode',
    method: 'post',
    data: data
  })
}

// 商户端扫码登陆-6.扫码登陆
export function scanLogin(data) {
  return request({
    url: '/jbl-user-center/api/merchant/v1/sysUser/scanLogin',
    method: 'post',
    data: data
  })
}

// 商户端-注册
export function phoneRegister(data) {
  return request({
    url: '/jbl-user-center/api/merchant/v1/sysUser/register',
    method: 'post',
    data: data
  })
}

// 商户端-获取openId
export function getOpenIdByUnionId(data) {
  return request({
    url: '/jbl-user-center/api/merchant/v1/sysUser/getOpenIdByUnionId',
    method: 'get',
    params: data
  })
}

export function getInfo(token) {
  return request({
    url: '/vue-element-admin/user/info',
    method: 'get',
    params: { token }
  })
}

// 商户端-判断是否绑定微信
export function isWxBind(data) {
  return request({
    url: '/jbl-user-center/api/common/v1/isWxBind',
    method: 'post',
    data: data
  })
}

// 商户端-微信解绑
export function wxUnBind(data) {
  return request({
    url: '/jbl-user-center/api/common/v1/wxUnBind',
    method: 'post',
    data: data
  })
}

// 根据unionid获取用户信息
export function selectUserInfoByUnionId(data) {
  return request({
    url: '/jbl-user-center/api/merchant/v1/sysUser/selectUserInfoByUnionId',
    method: 'get',
    params: data
  })
}

// 商户端扫码登陆-1.获取重定向地址url
export function getRedirectUrl(data) {
  return request({
    url: '/jbl-user-center/api/merchant/v1/sysUser/getRedirectUrl',
    method: 'get',
    params: data
  })
}

// 商户端扫码登陆-2.获取code
export function getCode(data) {
  return request({
    url: '/api/merchant/v1/sysUser/getCode',
    method: 'get',
    params: data
  })
}

// 商户端扫码登陆-3.getAccessToken
export function getAccessToken(data) {
  return request({
    url: '/jbl-user-center/api/merchant/v1/sysUser/getAccessToken',
    method: 'get',
    params: data
  })
}

// 商户端扫码登陆4-获取用户信息
export function getUserInfo(data) {
  return request({
    url: '/jbl-user-center/api/merchant/v1/sysUser/getUserInfo',
    method: 'get',
    params: data
  })
}

// 商户端扫码登陆-5.绑定微信
export function wxBind(data) {
  return request({
    url: '/jbl-user-center/api/merchant/v1/sysUser/wxBind',
    method: 'post',
    data: data
  })
}

// 机构分类
export function merchantType(query) {
  return request({
    url: '/jbl-business/api/v1/category/getByParentId',
    method: 'get',
    params: query
  })
}

// 获取所有标签
export function getAllLabels(query) {
  return request({
    url: '/jbl-business/api/merchant/v1/label/getByConditions',
    method: 'get',
    params: query
  })
}

// 分校管理---机构入住(调用时注意看下方的描述)
export function businessRegister(query) {
  return request({
    url: '/jbl-business/api/merchant/v1/business/register',
    method: 'post',
    data: query
  })
}

export function logout() {
  return request({
    url: '/vue-element-admin/user/logout',
    method: 'post'
  })
}
